package controllrs

import (
	"github.com/gin-gonic/gin"
	"jgame-api/app"
	"jgame-api/lang"
	"jgame-api/service"
	"strconv"
)

type UserController struct{}

func (u UserController) GetUserToken(c *gin.Context) {
	uidStr := c.Param("uid")
	if uidStr == "" {
		resError(c, lang.UidErrorData)
		return
	}

	uid, err := strconv.Atoi(uidStr)
	if err != nil {
		resError(c, lang.UidErrorData)
		return
	}

	token := service.GetUserToken(uid)
	app.Logger.Info("token=", token)

	resSuccess(c, map[string]any{
		"token": token,
	})
}
